<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="收货单" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/css/BillEdit.css" />
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function doSave(){
		document.getElementById("buttonDiv").style.display="none";
		document.getElementById("waitDiv").style.display="";
		<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';GATH_EXAM;')!=-1}">
			ShowConfirm('确认框','是否同时审核？',340,80,"doSaveCallBack()");
		</c:if>
		<c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';GATH_EXAM;')==-1}">
			frm.submit();
		</c:if>
	}
	function doSaveCallBack(){
		if(popRetVal!=null){
			document.getElementById("examine").value="1";
		}
		frm.submit();
	}
	function doCancel(){
		if(window.opener){
			window.close();
		}else{
			parent.ClosePop();
		}
	}
	function doPrint(id,favCost){
		if(favCost==0){
			ShowConfirm('确认框','收货单打印金额？',340,80,"doPrintCallBack("+id+")");
		}else{
			showWin(900,600,"/cooper/GatherBillPrint.ihtm?id="+id+"&print_cost=0");
		}
	}
	function doPrintCallBack(id){
		var printCost="0";
		if(popRetVal!=null){
			var printCost="1";
		}
		showWin(900,600,"/cooper/GatherBillPrint.ihtm?id="+id+"&print_cost="+printCost);
	}
	function doInit(){
		var itemNum=document.getElementById("item_num").value-0;
		if(itemNum>0){
			document.getElementById("amount_0").select();
		}else{
			document.getElementById("cancelButton").focus();
		}
		showFormErrorMsg();
		resizePopwin();
	}
</script>
</head>
<body onload="doInit();">
<div class="Wrap">
	<form name="frm" method="post">
	<div class="Container">
		<div class="Contnet Paper">
			<c:set var="pageTopTitle" value="收货单" />
			<c:set var="codeReadOnlyStr" value="" /><!-- 编码框是否可点击 -->
			<c:set var="codeReadOnlyClassStr" value="" /><!-- 编码框颜色 -->
			<c:if test="${command.codeRule.generateRule!='MANUAL'}">
				<c:set var="codeReadOnlyStr" value="readonly='readonly'" />
				<c:set var="codeReadOnlyClassStr" value="disabled" />
			</c:if>
			
			<c:set var="dateEdit" value="Y" /><!-- 是否可以编辑日期 -->
			<c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_BILL_DATE;')!=-1}">
				<c:set var="dateEdit" value="N" />
			</c:if>
			
			<c:if test="${command.gatherBill.enabled=='N' ||  currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';GATH_BILL;')==-1 || id!=null && id!='' && command.gatherBill.examined=='Y'}">
				<c:set var="disabledStr" value="disabled='true'" />
			</c:if>

			<!-- 提示信息 -->
			<%@ include file="../inc/BillPageTop.jsp"%>

			<!--单标题-->
			<br>
	        <table class="BillHeading" cellspacing="0" cellpadding="0">
	        	<tr>
		            <td width="301px;" rowspan="2" ><div class="CorpLogo"><img src="${enterpriseInfo.loginImage}" /></div></td>
		            <td width="301px;" rowspan="2" ><h1>${pageTopTitle}</h1></td>
		            <td width="301px;" class="tr vb codeTd">
		                <span class="MustInput">*</span>编号：
		                <spring:bind path="command.gatherBill.billCode">
				    	<input type="text" class="tbBillCode TextBox ${codeReadOnlyClassStr}" ${codeReadOnlyStr} maxlength="30" onKeyUp="goNextInput('deliverDateStr');" id="${status.expression}" name="${status.expression}" value="${status.value}">
				    	<script language="javascript">
							setFormErrorMsg('<c:out value="${status.errorMessage}" />',1,'gatherBill.billCode');
						</script>
			     		</spring:bind>
		            </td>
	        	</tr>
	        	<tr>
	            	<td class="tr" >
	            		<span id="calPosi"></span>
		            	<span class="MustInput">*</span>收货日期：
		            	<spring:bind path="command.gatherDateStr">
		                    <input type="text" class="tbBillDate_sim TextBox <c:if test="${dateEdit=='N'}">readonly</c:if>" maxlength="15" onKeyUp="goNextInput('gatherBill.linkman');" id="${status.expression}" name="${status.expression}" value="${status.value}" <c:if test="${dateEdit=='N'}">readonly="readonly"</c:if> />
		                    <c:if test="${dateEdit=='Y'}"><img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('gatherDateStr'),'yyyy-mm-dd',document.getElementById('calPosi'));"></c:if>
		                    <script language="javascript">
						    	setFormErrorMsg('<c:out value="${status.errorMessage}" />',2,'gatherDateStr');
						    </script>
		                </spring:bind>
	            	</td>
	        	</tr>
	        </table>

			<!-- 单头信息 -->
	        <div class="TopBottom_Border">
	        	<table class="BillHeadInfo" cellspacing="0" cellpadding="0">
	        		<tr>
	            		<td width="314px;">
	                		外协单位：${command.cooperatorName}
	            		</td>
	            		<td width="386px;">
	                		联系人：
	                		<spring:bind path="command.gatherBill.linkman">
	                    	<input type="text" class="tbHead2_1 TextBox" maxlength="15" onKeyUp="goNextInput('gatherBill.phone');" id="${status.expression}" name="${status.expression}" value="${status.value}" />
	                		<script language="javascript">
								setFormErrorMsg('<c:out value="${status.errorMessage}" />',4,'gatherBill.linkman');
							</script>
	                		</spring:bind>
	                		电话：
	                		<spring:bind path="command.gatherBill.phone">
	                    	<input type="text" class="tbHead2_2 TextBox" maxlength="40" onKeyUp="goNextInput('gatherBill.content');" id="${status.expression}" name="${status.expression}" value="${status.value}" />
	                    	<script language="javascript">
						    	setFormErrorMsg('<c:out value="${status.errorMessage}" />',5,'gatherBill.phone');
						    </script>
	                		</spring:bind>
	            		</td>
	            		<td width="204px;" class="tr">
	                		外协单号：${command.cbCode}
	            		</td>
	        		</tr>
	        	</table>
	        </div>

			<!-- 明细 -->
	        <input type="hidden" id="item_num" name="item_num" value="${fn:length(command.items)}">
	        <table id="BillDetails" class="BillDetails" width="100%" cellspacing="0" cellpadding="0">
	        	<tbody id="itemRowTbl">
	        	<tr>
					<th width="10%">项目类型</th>
					<th width="15%">内容</th>
					<th width="15%">材质</th>
					<th width="15%">规格</th>
					<th width="25%">制作要求</th>
					<th width="10%">外协数量</th>
					<th width="10%">本次收货</th>
				</tr>
				<c:forEach var="item" items="${command.items}" varStatus="i">
				<tr id="itemTr${i.index}">
					<td >
						<input class="TextBox readonly" readonly="readonly" type="text" style="width:68px" id="mt_name_${i.index}" name="mt_name_${i.index}" value="${item.makeTypeName}">
						<input type="hidden" id="id_${i.index}" name="id_${i.index}" value="${item.oldId}">
						<input type="hidden" id="cb_item_id_${i.index}" name="cb_item_id_${i.index}" value="${item.gatherBillItem.cbItemId}">
					</td>
					<td >
						<input type="text" class="TextBox readonly" readonly="readonly" style="width:110px" id="cont_${i.index}" name="cont_${i.index}" value="<c:out value="${item.finishedContent}" />">
					</td>
					<td >
						<input type="text" class="TextBox readonly" readonly="readonly" style="width:110px" id="pro_name_${i.index}" name="pro_name_${i.index}" value="${item.productName}">
					</td>
					<td >
						<input type="text" class="TextBox readonly" readonly="readonly" style="width:110px" id="spe_${i.index}" name="spe_${i.index}" value="<c:out value="${item.specification}" />">
					</td>
					<td >
						<input type="text" class="TextBox readonly" readonly="readonly" style="width:180px" id="req_${i.index}" name="req_${i.index}" value="<c:out value="${item.makeRequire}" />">
					</td>
					<td >
						<input type="text" class="TextBox readonly" readonly="readonly" style="width:68px" id="amount_total_${i.index}" name="amount_total_${i.index}" value='<commonTag:parseBigDecimal source="${item.amountTotal}" />'>
					</td>
					<td >
						<input type="text" class="TextBox" style="width:68px" maxlength="10" id="amount_${i.index}" name="amount_${i.index}" value="${item.amountStr}">
					</td>
				</tr>
				</c:forEach>
				</tbody>
			</table>
			
			<spring:bind path="command.items">
	        	<script language="javascript">
	          		setFormErrorMsg('<c:out value="${status.errorMessage}" />',9);
	        	</script>
			</spring:bind>
			
			<br>
			<!-- 单附加信息 -->
	        <div class="TopBottom_Border">
	        	<table class="BillElseInfo" cellspacing="0" cellpadding="0">
	        		<tr>
	            		<th width="84px">业务员：</th>
            			<td width="200px">${command.managerName}</td>
            			<th width="84px">摘要：</th>
            			<spring:bind path="command.gatherBill.content">
                		<td width="273px">
                			<input type="text" class="tbInfo2 TextBox" maxlength="200" onKeyUp="goNextInput('gatherBill.mark');" id="${status.expression}" name="${status.expression}" value="${status.value}">
                			<script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',11,'gatherBill.content');
					        </script>
                		</td>
            			</spring:bind>
            			<th width="84px">备注：</th>
            			<spring:bind path="command.gatherBill.mark">
            			<td width="179px">
            				<input type="text" class="TextBox" style="width:160px" maxlength="100" name="${status.expression}" id="${status.expression}" value="${status.value}">
            				<script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',12,'deliverBill.mark');
					        </script>
            			</td>
            			</spring:bind>
        			</tr>
        			
    			</table>
    		</div>
			<br>
			<div class="BillNotes">
				<span>开单人：${command.gatherBill.createrName} <c:if test="${command.gatherBill.createTime!=null}"><fmt:formatDate value="${command.gatherBill.createTime}" pattern="yyyy-MM-dd HH:mm"/></c:if></span>
				<span>审核人：<c:if test="${command.gatherBill.examinerId!=0}">${command.gatherBill.examinerName} <c:if test="${command.gatherBill.examineTime!=null}"><fmt:formatDate value="${command.gatherBill.examineTime}" pattern="yyyy-MM-dd HH:mm"/></c:if></c:if></span>
				<span>单据帐套：${command.tallySetName}</span>
				<spring:bind path="command.gatherBill.tallySetId">
			        <script language="javascript">
			        	setFormErrorMsg('<c:out value="${status.errorMessage}" />',1);
			        </script>
				</spring:bind>
			</div>
			
		</div>

		<!-- 业务单 底栏按钮 -->
		<div class="Footer">
			<div id="buttonDiv">
				<c:if test="${id!=null && id!=''}">
					<input type="button" class="buttom-a" value=" 打 印 " onClick="doPrint(${id},${command.favCost});" <c:if test="${command.gatherBill.enabled=='N'}">disabled='disabled'</c:if>>
				</c:if>
				<input type="button" class="buttom-a" value=" 保 存 " onClick="doSave();" ${disabledStr}>
				<input type="button" class="buttom-a" value=" 取 消 " onClick="doCancel();" id="cancelButton">
				<input type="hidden" id="examine" name="examine" value="0">
				<spring:bind path="command.sychronizeValue"><input type="hidden" name="${status.expression}" value="${status.value}"></spring:bind>
			</div>
			<div id="waitDiv" style="display:none">
    			<span>请稍候...</span>
			</div>
		</div>
		
	</div>
	</form>
</div>
</body>
</html>
